use serde::{Deserialize, Serialize};
use pyo3::prelude::*;

#[pyclass]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum Currency {
    CNY,
    USD,
    JPY,
    BTC,
}


#[pymethods]
impl Currency {
    pub fn rate(&self) -> u32 {
        match self {
            Currency::CNY => 100, 
            Currency::USD => 100, 
            Currency::JPY => 1, 
            Currency::BTC => 1e8 as u32, 
        }
    }
    pub fn from_f64(&self, amount: f64) -> i64 {
        (amount * self.rate() as f64).floor() as i64
    }
}